//
//  NearbyTableViewCell.m
//  God_is_a_Girl
//
//  Created by 杨文鹏 on 15/9/30.
//  Copyright (c) 2015年 呸. All rights reserved.
//

#import "NearbyTableViewCell.h"
#import <UIImageView+WebCache.h>
@implementation NearbyTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backimage = [[UIImageView alloc]init];
        self.backimage.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:self.backimage];
        
        self.imageview = [[UIImageView alloc]init];
//        self.imageview.backgroundColor = [UIColor cyanColor];
        [self.contentView addSubview:self.imageview];
        
        self.nameLabel = [[UILabel alloc]init];
//        self.nameLabel.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:self.nameLabel];
        
        self.DetailsLabel = [[UILabel alloc]init];
//        self.DetailsLabel.backgroundColor = [UIColor grayColor];
        self.DetailsLabel.font = [UIFont systemFontOfSize:10];
        [self.contentView addSubview:self.DetailsLabel];
        
        self.PeopleLabel = [[UILabel alloc]init];
//        self.PeopleLabel.backgroundColor = [UIColor greenColor];
        [self.contentView addSubview:self.PeopleLabel];
        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.backimage.frame = CGRectMake(self.frame.size.width / 40, self.frame.size.width / 40, self.frame.size.width * 38 / 40, 120);
    self.imageview.frame = CGRectMake(self.frame.size.width / 40 * 2, self.frame.size.width / 40 * 2, self.frame.size.width * 12 / 40, 120 - self.frame.size.width / 40 * 2);
    self.nameLabel.frame = CGRectMake(self.frame.size.width / 2.5, self.frame.size.width / 40 * 2, self.frame.size.width / 2, 30);
    self.DetailsLabel.frame = CGRectMake(self.frame.size.width / 2.5,55, self.frame.size.width / 2, 40);
    self.PeopleLabel.frame = CGRectMake(self.frame.size.width / 2.5,100, self.frame.size.width / 2, 20);
    
}

- (void)setModel:(NearbyModel *)model
{
    
    self.nameLabel.text = model.name;
    self.DetailsLabel.text = model.recommended_reason;
    self.PeopleLabel.text =     self.PeopleLabel.text = [NSString stringWithFormat:@"%@人去过",model.visited_count.stringValue];
    
    [self.imageview sd_setImageWithURL:[NSURL URLWithString:model.cover] placeholderImage:[UIImage imageNamed:@"search"]];
    
}







- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
